<template>
  <div class="Resume_div">
    <el-row class="Resume_row_top">
      <el-col :span="7">
        <div>
          <el-button size="mini" icon="el-icon-plus" @click="$router.push('/Resume/Edit')" type="success">新增
          </el-button>
        </div>
      </el-col>
      <el-col :span="12">
        <div><br /></div>
      </el-col>
      <el-col :span="5">
        <div>
          <el-input v-if="show" v-model="Name" @blur.prevent="changeCount()" class="Resume_row_top_input"
            prefix-icon="el-icon-search" placeholder="请输入姓名"></el-input>
        </div>
      </el-col>
    </el-row>
    <el-table :data="tableData.ResumeList" height="500" border>
      <el-table-column v-if="show" prop="item.pk_Resume" label="id" width="75"></el-table-column>
      <el-table-column prop="item.TypeNmae_CHS" label="类型" width="75"></el-table-column>
      <el-table-column prop="item.FullName" label="姓名" width="75"></el-table-column>
      <el-table-column prop="item.ImagePath" label="照片" width="75">
        <template slot-scope="scope">
          <div>
            <el-avatar :size="50" :src="'data:image/jpeg;base64,'+scope.row.ImagePath"></el-avatar>
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="item.Age" label="年龄" width="75"></el-table-column>
      <el-table-column prop="item.Province" label="户籍" width="75"></el-table-column>
      <el-table-column prop="item.Years" label="工作年限" width="100"></el-table-column>
      <el-table-column prop="item.CreateUserName" label="录入人" width="100"></el-table-column>
      <el-table-column prop="item.Birthday" label="出生日期" width="180">
        <template slot-scope="scope">
          <div>
            <span>{{scope.row.item.Birthday|TimeFilter}}</span>
          </div>
        </template>
      </el-table-column>
      <!--EndDate-->
      <el-table-column label="档期" width="300">
        <template slot-scope="scope">
          <div>
            <span
              v-if="scope.row.item">{{scope.row.item.StartDate|TimeFilter}}~{{scope.row.item.EndDate|TimeFilter}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="item.Description" label="备注" width="100%"></el-table-column>
      <el-table-column prop="item.StatusNmae_CHS" label="状态" width="100"></el-table-column>
      <el-table-column fixed="right" label="操作" width="180">
        <template slot-scope="scope">
          <el-button size="mini" icon="el-icon-edit-outline" @click="Update(scope.row.item)" type="primary">修改
          </el-button>
          <el-button size="mini" icon="el-icon-delete" @click="Del(scope.row.item)" type="danger">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-row class="Resume_row_paging">
      <el-col :span="5">
        <br>
      </el-col>
      <el-col :span="12">
        <div><br /></div>
      </el-col>
      <el-col :span="7">
        <div class="Resume_row_paging_col">
          <el-pagination background layout="prev, pager, next" :total="tableData.Count"
            :current-page.sync="AuditInfoPage" @current-change="ResumePage" :page-size="5">
          </el-pagination>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<style lang="scss" scoped>
.Resume_div {
  background-color: #ecf0f5;
}
.List_form input {
  width: 200px;
}
.Resume_row_top {
  height: 45px;
  margin-left: 10px;
}
.Resume_row_top button {
  margin-top: 9px;
}
.Resume_row_top_input {
  margin-top: 3px;
}
.Resume_row_paging {
  background-color: #fafafa;
}
.Resume_row_paging_col {
  float: right;
}
</style>
<script>
export default {
  data () {
    return {
      tableData: [
        {
          pk_Resume: "简历id",
          TypeNmae_CHS: "类型",
          FullName: "姓名",
          ImagePath: "照片",
          Age: "年龄",
          AnimalSign: "属相",
          Province: "户籍",
          Years: "工作年限",
          Tags1: "有效签证",
          Tags: "工作类型",
          UserFullName: "录入人",
          Birthday: "出生日期",
          StartDate: "开始档期",
          EndDate: "结束档期",
          Description: "备注",
          StatusNmae_CHS: "状态"
          //:"工作经历",
          //:"客户评论",
          //:"微信号",
          //:"身份证号",
          //:"手机号",
          //:"应急电话",
          //:"家庭住址",
          //:"家庭情况",
          //:"备注信息",
          //:"头像图片",
        }
      ],
      dialogFormVisible: false,
      form: {
        TypeNmae_CHS: '',
        StatusNmae_CHS: '',
        FullName: '',
        UserFullName: "",
        StartDate: '2020/2/2',
        EndDate: '2020/2/3',
        imageUrl: '',
        ImgDt: ''
      },
      rules: {

        FullName: [
          { required: true, message: '名称不能为空', trigger: 'blur' }
        ],
        UserFullName: [
          { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
        ],
        StartDate: [
          { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
        ]
      },
      AuditInfoPage: 1,
      AuditInfo: [],
      Name: null,
      show: false
    };
  },
  //传当前行的数据 将操作方式该改为修改
  methods: {
    Update (row) {
      var type = 'Update';
      this.$router.push({
        path: '/Resume/Edit', query: {
          pk_Resume: row.pk_Resume
        }
      });
    },
    ResumePage () {
      this.$axios({
        url: '/HrApi/Resume/GetResumeInfo',
        method: 'Get',
        params: {
          page: this.AuditInfoPage,
          limit: 5
        }
      }).then(res => {
        this.imageUrl = 'data:image/jpeg;base64,' + res.data.ImgDt;
        this.tableData = res.data.data
      })
    },
    changeCount: function () {
      this.$axios({
        url: '/HrApi/Resume/GetResume_ListAll',
        method: 'Get',
        params: {
          page: this.AuditInfoPage,
          limit: 5,
          Name: this.Name
        }
      }).then(res => {
        this.tableData = res.data.data
      })
    },
    Del (row) {
      this.$confirm('此操作将永久删除该简历, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios({
          url: '/HrApi/Resume/DelResume_List',
          method: 'POST',
          params: {
            pk_Resume: row.pk_Resume
          }
        }).then(res => {
          if (!res.data.code) {
            this.$message({
              message: res.data.msg,
              type: 'success'
            });
            this.ResumePage();
          } else {
            this.$message(res.data.msg)
          }

        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    }
  },
  mounted () {
    this.ResumePage();
  },
  filters: {
    //时间过滤器
    TimeFilter (t) {
      if (t == null) {
        return '无'
      }
      let dt = t.split('T').join(' ')
      if (dt.split('.').length > 1) {
        dt = dt.split('.')[0]
      }
      return dt;
    }
  }
};
</script>
